package common

import (
	"github.com/edgexfoundry/edgex-go/internal/app/dtos"
)

type PageEntity interface {
	dtos.Device | dtos.DeviceResource | dtos.DeviceCommand | dtos.Transport
}

type PageInfo[T PageEntity] struct {
	dtos.PageInfoBase
	Data []T `json:"data,omitempty"`
}

func NewPageInfo[T PageEntity](page, pageSize int, totalCount uint32, ps []T) PageInfo[T] {

	return PageInfo[T]{
		PageInfoBase: dtos.PageInfoBase{
			Page:       page,
			PageSize:   pageSize,
			TotalCount: totalCount,
		},
		Data: ps,
	}
}
